﻿<%@ page contentType="text/html; charset=GBK"  language="java" %>

<%@ taglib uri="/component/tree" prefix="component" %>

<%@page import="java.util.*"%>

<%
	String context = request.getContextPath();
	
%>
	

<%@page import="component.tree.util.ConfigUtil"%>

<html>
<head>

<style type="text/css">
<!--
.div {
	background-color:#FFFFFF;
	width: 300px;
	height: 370px;
	overflow:auto;
	border: 1px solid black;
	border-color:#CCCCCC;
	border-left-color: #FFFFFF;
	border-left-style: inset;
	border-left-width: 2px;
	border-top-style: inset;
	border-top-width: 2px;
	overflow:auto;
}

-->
</style>

<% 
	out.println(ConfigUtil.getImportTreeJs());
	out.println(ConfigUtil.getImportTreeCss());
%>
	
</head>

<center>

<table>
	<tr>
		<td width="10px"> &nbsp;</td>
		<td valign="top" align="left">		
        	<span><font size="3"><strong>单位</strong></font><font size="2">(单选)</font></span>       
			<div id="tree-div" class="div" >
				<component:tree id="orgTreeObj" componentId="SMG_TORGANIZATION" title="单位" 
								loadAllAble="true" firstShowLevel="2" />				
			</div>	
		</td>
		
		<td width="50px"> &nbsp;</td>
		
		<td valign="top" align="left">
			<span><font size="3"><strong>收费项目</strong></font><font size="2">（多选）</font></span>    
			<div id="tree-div" class="div" >
				<component:tree id="insubjTreeObj" componentId="TFM_PB_TINSUBJ"  
								loadAllAble="true" selectMoreAble="true" firstShowLevel="2" />													
			</div>
		</td>
	
	</tr>
	
	<tr>
		<td width="10px">&nbsp;</td>
		<td><input type="text" size="41" id ="orgName" name="orgName"/></td>
		
		<td> &nbsp;</td>
		<td><input type="text" size="41" id ="insubjName" name="insubjName"/></td>
	</tr>
				
	<tr>
		<td width="10px">&nbsp;</td>
		<td valign="middle" align="center"><input type="button" id ="" name="" value="确 定" onclick="doReturn()"/></td>
		
		<td> &nbsp;</td>
		<td valign="middle" align="center"><input type="button" id ="" name="" value="关 闭" onclick="javascript:window.close();"/></td>
	</tr>
</table>

</center>

</html>

<script type="text/javascript">

insubjTreeObj.condition = "  and fyear='2009' ";

window.onload = function(){
	orgTreeObj.onDblClickNode = function(){};//屏蔽双击事件
}

function orgTreeObj_onClick(){
	document.getElementById("orgName").value = orgTreeObj.objMap.get("name");	
}

function insubjTreeObj_onNodeSelect(){
	var selectMap = insubjTreeObj.getSelectTreeMap2();
	document.getElementById("insubjName").value = selectMap.get("name");
}

var win = window.dialogArguments;

function doReturn(){
	var orgName = document.getElementById("orgName").value;
 	if(orgName=="" || orgName=="undefined"){l
		alert("请选择单位！");return false;
 	 }
	 
	var insubjName = document.getElementById("insubjName").value;	
	if(insubjName=="" || insubjName=="undefined"){
		alert("请选择收费项目！");return false;
 	 }

	//win.document.all.subId.value=warrant.objMap.get("id");
	//win.document.all.subPath.value=warrant.objMap.get("name");
	 
	var selectTreeArr = treeObj.getSelectTreeMap();   
	selectInsubj(selectTreeArr);
	//window.returnValue="succ";
	//window.close();
}



//选择收费项目的叶子节点
function selectInsubj(selectTreeArr){	
	var nameStr="";
	var idStr="";
	if(selectTreeArr.length>0){
		for( i=0;i<selectTreeArr.length;i++){
			var tempMap = selectTreeArr[i];		
			var nodeName = tempMap.get("name");
			var id = tempMap.get("id");
			var type = tempMap.get("type");						
			if(type==0){//叶子节点
			 	nameStr += nodeName+",";
				idStr += id+",";
			}			
		}
	}
	nameStr = nameStr.substring(0,nameStr.length-1);
	idStr = idStr.substring(0,idStr.length-1);

	//win.document.all.insubjId.value = idStr;
	//win.document.all.insubjName.value = nameStr;
}	


</script>
